//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Windows.Data;

namespace OpenLS.Spreadsheet.UI.Internals
{
    public class RootGroupAccessor: IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var worksheet = StrictConverter.Convert<Worksheet>(value);
            if (worksheet == null)
                return worksheet;
            switch (parameter as string)
            {
                case "columns":
                    return worksheet.RootColumnGroup;
                case "rows":
                    return worksheet.RootRowGroup;
                    default: throw  new NotSupportedException();
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion
    }
}
